<?php
use \phiction\tester as t;
use \modules\auth\security as s;

return [
    'random-id' => function () {
        $id = s::random_id();
        t::must_equal(strlen($id), s::RANDOM_ID_LENGTH);
        var_dump($id);
    },
    'make-credential' => function () {
        var_dump(s::make_credential(str_repeat(' ', 64)));
    },
    '!credential-long-password' => function () {
        var_dump(s::make_credential(str_repeat(' ', 65)));
    },
    'make-token' => function () {
        $cred = s::make_credential(str_repeat(' ', 64));
        var_dump(s::make_token([ 'credential' => $cred ]));
    },
    'break-token' => function () {
        $cred = s::make_credential(str_repeat(' ', 64));
        $token = s::make_token([ 'credential' => $cred ]);
        $shards = s::break_token($token);
        t::assert(is_array($shards), "shards must be an array");
        var_dump($shards);
    },
    'renew-token' => function () {
        $cred = s::make_credential(str_repeat(' ', 64));
        var_dump(s::make_token([ 'credential' => $cred ]));
    },
    '!key-is-private' => function () {
        var_dump(s::key());
    },
];

